package com.shrcl.engineerprocess.domain.impl;

import com.google.common.base.Objects;
import com.shrcl.engineerprocess.domain.TSCProcessRole;
import com.shrcl.engineerprocess.domain.proxy.TSCProcessRoleProxy;
import com.shrct.businessprocess.organization.RCEmployee;
import com.shrct.businessprocess.organization.impl.RCEmployeeImpl;
import com.uniquesoft.uidl.validation.Validates;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("TSCPROCESSROLE_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "tscprocessrole")
public class TSCProcessRoleImpl extends BaseModelObject implements TSCProcessRole {
  public TSCProcessRoleImpl() {
    super();
  }
  
  @JoinColumn(name = "firstLevelVerifier_id")
  @ManyToOne(targetEntity = RCEmployeeImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCEmployee firstLevelVerifier;
  
  public RCEmployee getFirstLevelVerifier() {
    return this.firstLevelVerifier;
  }
  
  public TSCProcessRole setFirstLevelVerifier(final RCEmployee firstLevelVerifier) {
    this.firstLevelVerifier = firstLevelVerifier;
    return this;			
    
  }
  
  @JoinColumn(name = "secondLevelVerifier_id")
  @ManyToOne(targetEntity = RCEmployeeImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCEmployee secondLevelVerifier;
  
  public RCEmployee getSecondLevelVerifier() {
    return this.secondLevelVerifier;
  }
  
  public TSCProcessRole setSecondLevelVerifier(final RCEmployee secondLevelVerifier) {
    this.secondLevelVerifier = secondLevelVerifier;
    return this;			
    
  }
  
  public void update(final Procedure1<? super TSCProcessRole> updater) {
    updater.apply(this);
  }
  
  public void checkValid() {
    boolean _notEquals = (!Objects.equal(this.firstLevelVerifier, null));
    Validates.Assert(_notEquals, "TSC\u6280\u672F\u7ECF\u7406\u4E0D\u80FD\u4E3A\u7A7A");
    boolean _notEquals_1 = (!Objects.equal(this.secondLevelVerifier, null));
    Validates.Assert(_notEquals_1, "CTO\u8BBE\u5B9A\u4E0D\u80FD\u4E3A\u7A7A");
  }
  
  public static TSCProcessRole create(final IObjectFactory objectFactory) {
    com.shrcl.engineerprocess.domain.TSCProcessRole tSCProcessRole = new com.shrcl.engineerprocess.domain.impl.TSCProcessRoleImpl(
    );
    objectFactory.create(tSCProcessRole);
    return tSCProcessRole;			
    
  }
  
  public static TSCProcessRole createTSCProcessRoleImpl(final IObjectFactory objectFactory, final Procedure1<TSCProcessRole> init) {
    com.shrcl.engineerprocess.domain.TSCProcessRole tSCProcessRole = new com.shrcl.engineerprocess.domain.impl.TSCProcessRoleImpl(
    );
    objectFactory.create(tSCProcessRole);
    init.apply(tSCProcessRole);
    
    return tSCProcessRole;			
    
  }
  
  public TSCProcessRoleProxy toProxy() {
    com.shrcl.engineerprocess.domain.proxy.TSCProcessRoleProxy proxy = new com.shrcl.engineerprocess.domain.proxy.TSCProcessRoleProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
